#include <iostream>  
#include <string>
#include <algorithm>
#include <limits.h>

using namespace std;

int main()
{
    string s;
    cin >> s;

    int n = s.size();
    int a[27] = { 0 };

    for (int i = 0; i < n; i++)
    {
        a[s[i] - 'a']++;
    }

    int gmax = INT_MIN;
    int gmin = INT_MAX;

    for (int i = 0; i < 26; i++)
    {
        if (a[i] != 0)
        {
            gmax = max(gmax, a[i]);
            gmin = min(gmin, a[i]);
        }
    }

    cout << gmax - gmin << endl;
    return 0;
}